<?php

namespace app\mall\ui\form;

use app\mall\enum\YesNoEnum;
use app\mall\model\MallUserLevelSetting;

/**
 * 商城会员表单
 */
class MallUserForm
{
    public function nickname()
    {
        return [
            'type' => 'input',
            'title' => '昵称',
            'field' => 'nickname',
            'validate' => [
                [
                    'required' => true,
                    'message' => '不能为空',
                ],
            ],
        ];
    }

    public function avatar()
    {
        return [
            'type' => 'uploadImage',
            'action' => config('thinkAdmin.upload_url'),
            'title' => '头像',
            'field' => 'avatar',
        ];
    }

    public function phone()
    {
        return [
            'type' => 'input',
            'title' => '手机号',
            'field' => 'phone',
            'validate' => [
                [
                    'required' => true,
                    'message' => '不能为空',
                ],
            ],
        ];
    }

    public function level_flag()
    {
        return [
            'type' => 'select',
            'title' => '等级',
            'field' => 'level_flag',
            'options' => MallUserLevelSetting::buildLevelOptions(),
            'validate' => [
                ['required' => true, 'message' => '不能为空']
            ]
        ];
    }

    public function mail()
    {
        return [
            'type' => 'input',
            'title' => '邮箱',
            'field' => 'mail',
        ];
    }

    public function vip_expire_time()
    {
        return [
            'type' => 'date',
            'title' => 'vip到期时间',
            'field' => 'vip_expire_time',
        ];
    }

    public function money()
    {
        return [
            'type' => 'number',
            'title' => '账户余额',
            'field' => 'money',
            'props' => [
                'precision' => 2,
            ],
        ];
    }

    public function point()
    {
        return [
            'type' => 'number',
            'title' => '积分',
            'field' => 'point',
        ];
    }

    public function enable()
    {
        return [
            'type' => 'radio',
            'options' => YesNoEnum::toZhArrayForSelect(),
            'title' => '是否有效',
            'field' => 'enable',
        ];
    }
}